package net.sx.minemodule.mvp.presenters;

import android.text.TextUtils;

import com.alibaba.fastjson.JSON;
import com.kedll.library.mvp.AbstractRefreshPresenter;
import com.kedll.library.mvp.RefreshingView;
import com.kedll.library.util.Log;

import net.sx.minemodule.MineApiUtils;
import net.sx.minemodule.mvp.bean.StylistCollectBean;

import java.util.List;
import java.util.Random;

/**
 * 设计师收藏
 *
 * @author 11470
 */
public class MineStylistCollectPresenter extends AbstractRefreshPresenter<RefreshingView> {

    private Random random;

    public MineStylistCollectPresenter(RefreshingView mView) {
        super(mView);
        random = new Random();
    }

    @Override
    protected void fetchData(boolean isLoadMore) {
        MineApiUtils.getMyCollectionStylistList(subModelList -> {
            if (TextUtils.isEmpty(subModelList.getItems())) {
                return;
            }
            Log.e("---",subModelList.getItems());
            List<StylistCollectBean> beanList = JSON.parseArray(subModelList.getItems(), StylistCollectBean.class);
            parserData(isLoadMore, beanList);
        }, throwable -> {

        });
//        addSubscription(Observable.range(0, 5)
//                .map(integer -> {
//                    StylistCollectBean bean = new StylistCollectBean();
//                    bean.setName("剃须刀");
//                    bean.setHeadPath("https://picsum.photos/300/300/?random" + random.nextInt());
//                    return bean;
//                })
//                .toList()
//                .subscribe(bean -> parserData(isLoadMore, bean)));
    }
}
